<style>
	.bb-content1-heade{
		background: #aaa;
		text-align: center;
		
	}
	.bb-header{
		background:#f4f9f9;
		margin-top: 10px;
		width: 100%;
		min-width: 1000px;
		overflow:hidden; 
	}
	.bb-header select{
		color: #666;
		width: 200px;
		height: 30px;
		margin-left: 10px;
		background: #f0f3f4;
		border-radius: 5px;
	}
	.bb-header .morefind {
		width: 250px; 
		float: right;
	}
	.bb-header .morefind :nth-child(1){
		width: 100px;
		height: 30px;
		float: left;
		color: #1591FB;
		text-align: center;
		line-height: 30px;
	}
	.bb-header .morefind span:hover{
		cursor: pointer
	}
	.bb-header .morefind :nth-child(2){
		float: right;
		text-align: center;
		border-radius: 5px;
		line-height: 30px;
		width:100px;
		margin-left: 10px;
		height: 30px;
		color: #fff;
		background: #999;
	}
	.bb-header div{
		float: left;
	}
	.bb-title{
		padding-top: 20px;
		width: 100%;
		min-width: 1000px;
		font-size: 25px;
		font-weight: 900;
		overflow:hidden; 
		text-align: center;
		position: relative;
	}
	.posi-center{
		position: absolute;
		width:200px;
		top: 20px;
		left: 50%;
		margin-left: -100px;
	}
	.bb-title a {
		font-size: 15px;
		font-weight: 0;
		line-height: 50px;
		width: 150px;
		height: 50px;
		float: right;
	}
	.bb-all{
		position: relative;
		width: 100%;
		overflow-x: scroll;
	}
	.bb-tab{
		font-size: 18px;
		min-width: 1000px;
		overflow: hidden;
	}
	.bb-tab span{
		width: 125px; 
		height: 30px;
		line-height: 30px;
		float: left;
		text-align: center;
	}
	.bb-tab div span:nth-child(1){
		width: 300px;
	}
	.bb-tab div {
		float: right;
		width: 500px;
		font-size: 15px;
		color: #999;
	}
	.bb-tab div span{
		width: 200px;
		float: left;
		text-align: center;
		line-height: 30px;
	}
	table{
		width: 100%;
		min-width: 1000px;
		text-align: center;
		font-size: 18px;

	}

	table th{
		text-align: center;
		color:#fff;
		background: #aaa;

	}
	.bb-content1{
		width: 100%;
		padding-top: 20px;
		min-width: 1000px;
	}
	.bb-content2{
		padding-top: 20px;
		width: 1000px;
		margin:0 auto;
	}
	.bb-content2-canvas{

		width: 1000px;
		overflow:hidden;
		margin:0 auto; 
	}
	#eath{	box-shadow: 5px 5px 5px #aaa;
			width: 40%;float: left;
			min-height:400px;
			min-width: 400px;
			margin-left: 10px;
			background: #666;
		}
	#hutou{	box-shadow: 5px 5px 5px #aaa;
			width: 40%;
			margin-right:10px;
			float: right;
			min-height: 400px;
			min-width: 400px;
			background: #666;
		}
	.bb-content3{
		margin-top:20px; 
		width: 1100px;
		margin:0 auto; 
		margin-top: 20px;
	}
	.bb-content3 table{
		border:1px solid #fff;
		margin-left: 30px;
		padding-top: 20px;
		position: relative;
		border:none;
	}
	.bb-content2 table{
		margin-top: 20px;
		position: relative;
		border:2px solid #fff;
	}
	.bb-content1 table{

		margin-top: 20px;
		position: relative;
		border:2px solid #fff;
	}
	.tab-bigtable{
		
	}
	.bb-content2 table td{
		/*width:150px;*/
		height: 60px;
	}
	.tab-table{
		font-size: 15px;
		color: #999;
	}
	.tab-bigtable-div{
			width: 20px;
			height: 20px;
			position: absolute;
			left: -30px;
		}
	.small-table{
		text-align: right;
		border:0px solid;
	}
	.morediv{
		position: absolute;
		z-index: 999;
		top: -230px;
		padding-left: 20px;
		padding-top: 20px;
		width: 100%;
		height: 230px;
		min-width: 1000px;
		background: #fff;
		overflow: hidden;
		animation: down 2s;
	}
	@-webkit-keyframes  down{
		0% {top:-230px;  }
		50% {top: 0px;  }
		100% {top:-230px;  }
	}
	@-o-keyframes  down{
		0% {top:-230px;  }
		50% {top: 0px;  }
		100% {top:-230px;  }
	}
	@-moz-keyframes  down{
		0% {top:-230px;  }
		50% {top: 0px;  }
		100% {top:-230px;  }
	}
	@keyframes  down{
		0% {top:-230px;  }
		50% {top: 0px;  }
		100% {top:-230px;  }
	}
	.more-left{
		color: #aaa;
		min-width: 210px;
		width: 230px;
		position: relative;
		float: left;
	}.more-left input{
		width:150px;
		height: 30px; 
	}
	.more-left p{
		color: black;
		font-weight: 900;
	}
	.more-line{
		width: 1px;
		background: #aaa;
		height: 150px;
		position: absolute;
		right: 0px; top: 50px;
	}
	.more-center{
		float: left;
		width: 50%;
		min-width: 490px;
		padding-left: 10px;
	}
	.more-center p{
		font-weight: 900;
		padding-bottom: 20px;
	}
	.more-center p span{
		width:100%;
		font-weight: 0;
		min-width: 130px;
		float: left;
		text-align: center;
		margin-left:20px;
		color: #1591FB;
		border-radius: 5px;
		font-size: 20px;
		border:1px solid #1591FB;
	}
	.more-right{
		width: 20%;
		min-width:230px;
		float: right;
		padding-right: 20px;
		position: relative;
	}
	.more-right p span:nth-child(1){
		float: right;
		text-align: center;
		border-radius: 5px;
		line-height: 30px;
		width:100px;
		margin-left: 10px;
		height: 30px;
		color: #fff;
		background: #999;
	}
	.more-right p span:nth-child(2){
		float: right;
		text-align: center;
		border-radius: 5px;
		line-height: 30px;
		width:100px;
		height: 30px;
		color: #fff;
		background: #1591FB;
	}
	.more-up{
		height: 30px;
		position: absolute;
		right: 40px;
		bottom: 0px;
		color: #1591FB;
	}
	.more-up:hover{
		color: #999;
	}
	.bb-content3 i{
		color:#D6EBFE;
	}
	.bb-content3 i:hover{
		color: #1591FB;
		transition:.5s;
	}
</style>
<div ng-controller="Daytake">
	<div class="bg-light lter b-b wrapper-md">
		<h1 class="m-n font-thin h3">日经营分析报告</h1>
	</div>
	<div class="bb-all">
			<div class="morediv">
					<div class="more-left">

						<p>时间筛选：</p>
						<label >选择日期查询</label>	
						<input type="date" ng-model='endTime'> 
						<i class="fa fa-calendar fa-2x" aria-hidden="true"></i>
						<div class="more-line">
						</div>
					</div>
					<div class="more-center" ng-if='tab!=3'>
						<p>区域单位筛选:</p>
						<p>
							<span ng-if="tab==2">当前分公司:{{dept.Name}}</span>
							<span  ng-if="tab==1">当前供应单位:{{providerType==''?'全部':(providerType==0?'钢厂':(providerType==1?'仓库':'经销商'))}}</span>
						</p>
					</div>
					<div class="more-right">
						<p>
							<span ng-click='update()'>重置条件</span>
							<span ng-click='tab==1?GetCaixiao():(tab==2?GetYingshou():Getkucun())'>查询</span>
						</p>
					</div>
					<i class="fa fa-sort-asc fa-4x more-up" aria-hidden="true" ng-click='upload()'></i>
			</div>
		    <div>
				<div class="bb-header">
					<div>
						<select placeholder="按事业部查找" ng-options=" x.Name for x in array track by x.Id" ng-show="tab==2" ng-change='tab==1?GetCaixiao(providerType):(tab==2?GetYingshou():$scope.Getkucun())' ng-model="dept">
							<option ng-value="{{null}}">查看全部</option>
						</select>
						<!-- <select  ng-model="QuYu" ng-show="tab==2" ng-change='tab==1?GetCaixiao(providerType):(tab==2?GetYingshou():$scope.Getkucun())'> -->
						<!-- 	<option>请选择大区</option>
							<option value="">查看全部</option>
							<option ng-repeat='x in arrT' value={{x.Id}}>{{x.name}}</option>
						</select> -->
						<select name="" id="" ng-model='providerType' ng-show='tab==1' ng-change='tab==1?GetCaixiao(providerType):(tab==2?GetYingshou():$scope.Getkucun())'>
							<option value="">请输入供应单位类型</option>
							<option value="0">钢厂</option>
							<option value="1">仓库</option>
							<option value="2">经销商</option>
						</select>
					</div>
					<div class="morefind" ng-if="tab!=3">
						<span ng-click='down()' >更多查询条件</span>
						<span ng-click='update()'>重置条件</span>
					</div>	
				</div>
				<div class="bb-title">
					<span class="posi-center">日经营分析报告</span>
					<a href="../api/Report/ExpSalesReport?isHander = true&startTime={{startTime1}}&endTime ={{endTime1}}&providerType={{providerType}}" ng-if="tab==1">
						<span>
							<i class="fa fa-file-excel-o fa-2x" aria-hidden="true" style="color: green"></i>导出
						</span>
					</a>
					<a href="../api/Report/ExpAccountsReport?isHander = true&startTime={{startTime}}&endTime ={{endTime}}&providerType={{providerType}}" ng-if="tab==2">
						<span>
							<i class="fa fa-file-excel-o fa-2x" aria-hidden="true" style="color: green"></i>导出
						</span>
					</a>
					<a href="../api/Report/ExpNowDepotProfitReport?supplierId=null" ng-if="tab==3">
						<span>
							<i class="fa fa-file-excel-o fa-2x" aria-hidden="true" style="color: green"></i>导出
						</span>
					</a>
				</div>
				<div class="bb-tab">
					<span ng-click='tab1()'>采销情况</span>
					<span ng-click='tab2()'>应收账务</span>
					<span ng-click='tab3()'>库存权益</span>
					<div>
						<span ng-if="endTime==null">查询日期：全部</span>
						<span ng-if="endTime!=null">查询日期：{{startTime==null?'全部':(startTime| date:'yyyy-MM-dd')}}~{{endTime| date:'yyyy-MM-dd'}}</span>
						<span ng-if="tab==1">查询范围：{{providerType==''?'全部':(providerType==0?'钢厂':(providerType==1?'仓库':'经销商'))}}</span>
						<span ng-if="tab==2" >查询范围:{{dept.Name}}</span>
					</div>
				</div>
				<div class="bb-content">
					<!-- 采销情况 -->
					<div class="bb-content1" ng-if='tab==1'>
						<table class="bb-table" border="2px" >
							<tr>
								<th rowspan="2">供应商类型</th>
								<th rowspan="2">供应单位名称</th>
								<th colspan="3">销售指标</th>
								<th colspan="3">利润指标</th>
								<th colspan="3">采购指标</th>
							</tr>
							<tr>
								<th >今日销售数量</th>
								<th >累计销售数量</th>
								<th >累积预售数量</th>
								<th >当日毛利额</th>
								<th >累积毛利额</th>
								<th >返利金额</th>
								<th >累计采购量</th>
								<th >合计锁货数量</th>
								<th >厂家余款</th>
							</tr>
							<tr ng-repeat="item in gangchang">
								<td ng-if="$index == 0" rowspan="{{gangchang.length}}">
									钢厂
								</td>
								<td>{{item.Name}}</td>
								<td>{{item.DayCount}}</td>
								<td>{{item.TotalCount}}</td>
								<td>{{item.OldTotalCount}}</td>
								<td>{{item.DayProfit}}</td>
								<td>{{item.TotalProfit}}</td>
								<td>{{item.RebateMoney}}</td>
								<td>{{item.TotalPurchase}}</td>
								<td><span style="color:#1591FB;text-decoration:underline ">{{item.LockGoodsCount}}</span></td>
								<td>{{item.BalanceMoney}}</td>
							</tr>
							<tr style="background: #ddd;font-weight: 600;" ng-if="gangchang.length!=0&&(providerType==0||providerType=='')">
								<td colspan="2">小计</td>
								<td ng-bind="arrSumG.DayCount| number:3"></td>
								<td ng-bind="arrSumG.TotalCount| number:3"></td>
								<td ng-bind="arrSumG.OldTotalCount| number:3"></td>
								<td ng-bind="arrSumG.DayProfit| number:3"></td>
								<td ng-bind="arrSumG.TotalProfit| number:3"></td>
								<td ng-bind="arrSumG.RebateMoney| number:3"></td>
								<td ng-bind="arrSumG.TotalPurchase| number:3"></td>
								<td ng-bind="arrSumG.LockGoodsCount| number:3"></td>
								<td ng-bind="arrSumG.BalanceMoney| number:3"></td>
							</tr>
							<tr ng-repeat="item in cangku">
							<td ng-if="$index == 0" rowspan="{{cangku.length}}">
								仓库
							</td>
								<td>{{item.Name}}</td>
								<td>{{item.DayCount}}</td>
								<td>{{item.TotalCount}}</td>
								<td>{{item.OldTotalCount}}</td>
								<td>{{item.DayProfit}}</td>
								<td>{{item.TotalProfit}}</td>
								<td>{{item.RebateMoney}}</td>
								<td>{{item.TotalPurchase==null?0:item.TotalPurchase}}</td>
								<td>{{item.LockGoodsCount==null?0:item.LockGoodsCount}}</td>
								<td>{{item.BalanceMoney==null?0:item.BalanceMoney}}</td>
							</tr>
							<tr style="background: #ddd;font-weight: 600;" ng-if="cangku.length!=0&&(providerType==1||providerType=='')">
								<td colspan="2" >小计</td>
								<td ng-bind="arrSumC.DayCount| number:3"></td>
								<td ng-bind="arrSumC.TotalCount| number:3"></td>
								<td ng-bind="arrSumC.OldTotalCount| number:3"></td>
								<td ng-bind="arrSumC.DayProfit| number:3"></td>
								<td ng-bind="arrSumC.TotalProfit| number:3"></td>
								<td ng-bind="arrSumC.RebateMoney| number:3"></td>
								<td ng-bind="arrSumC.TotalPurchase==null?0:arrSumC.TotalPurchase | number:3"></td>
								<td ng-bind="arrSumC.LockGoodsCount==null?0:arrSumC.LockGoodsCount| number:3"></td>
								<td ng-bind="arrSumC.BalanceMoney==null?0:arrSumC.BalanceMoney| number:3"></td>
							</tr>
							<tr ng-repeat="item in jingxiao">
							<td ng-if="$index == 0" rowspan="{{jingxiao.length}}">
								经销商
							</td>
								<td>{{item.Name}}</td>
								<td>{{item.DayCount}}</td>
								<td>{{item.TotalCount}}</td>
								<td>{{item.OldTotalCount}}</td>
								<td>{{item.DayProfit}}</td>
								<td>{{item.TotalProfit}}</td>
								<td>{{item.RebateMoney}}</td>
								<td>{{item.TotalPurchase==null?0:item.TotalPurchase}}</td>
								<td>{{item.LockGoodsCount==null?0:item.LockGoodsCount}}</td>
								<td>{{item.BalanceMoney==null?0:item.BalanceMoney}}</td>
							</tr>
							<tr style="background: #ddd;font-weight: 600;" ng-if="jingxiao.length!=0&&(providerType==2||providerType=='')">
								<td colspan="2" >小计</td>
								<td ng-bind="arrSumJ.DayCount| number:3"></td>
								<td ng-bind="arrSumJ.TotalCount| number:3"></td>
								<td ng-bind="arrSumJ.OldTotalCount| number:3"></td>
								<td ng-bind="arrSumJ.DayProfit| number:3"></td>
								<td ng-bind="arrSumJ.TotalProfit| number:3"></td>
								<td ng-bind="arrSumJ.RebateMoney| number:3"></td>
								<td ng-bind="arrSumJ.TotalPurchase==null?0:arrSumJ.TotalPurchase | number:3"></td>
								<td ng-bind="arrSumJ.LockGoodsCount==null?0:arrSumJ.LockGoodsCount| number:3"></td>
								<td ng-bind="arrSumJ.BalanceMoney==null?0:arrSumJ.BalanceMoney| number:3"></td>
							</tr>
							<tr>
							<th colspan="2">合计</th>
								<th ng-bind="arrSumC.DayCount+arrSumG.DayCount+arrSumJ.DayCount| number:3">1</th>
								<th ng-bind="arrSumC.TotalCount+arrSumG.TotalCount+arrSumJ.TotalCount| number:3">2</th>
								<th ng-bind="arrSumC.OldTotalCount+arrSumG.OldTotalCount+arrSumJ.OldTotalCount| number:3">3</th>
								<th ng-bind="arrSumC.DayProfit+arrSumG.DayProfit+arrSumJ.DayProfit| number:3">4</th>
								<th ng-bind="arrSumC.TotalProfit+arrSumG.TotalProfit+arrSumJ.TotalProfit| number:3">5</th>
								<th ng-bind="arrSumC.RebateMoney+arrSumG.RebateMoney+arrSumJ.RebateMoney| number:3">6</th>
								<th ng-bind="(arrSumC.TotalPurchase==null?0:arrSumC.TotalPurchase)+arrSumG.TotalPurchase+arrSumJ.TotalPurchase| number:3">7</th>
								<th ng-bind="(arrSumC.LockGoodsCount==null?0:arrSumC.LockGoodsCount)+arrSumG.LockGoodsCount+arrSumJ.LockGoodsCount| number:3">8</th>
								<th ng-bind="(arrSumC.BalanceMoney==null?0:arrSumC.BalanceMoney)+arrSumG.BalanceMoney+arrSumJ.BalanceMoney| number:3">9</th>
							</tr>
						</table>
					</div>
					<!-- 应收账务 -->
					<div class="bb-content2" ng-show='tab==2'>
						<div class="bb-content2-canvas">
							<div id="eath">
							</div>
							<div id="hutou">
							</div>
						</div>
						<table border="2px">
							<tr>
								<th>分公司名称</th>
								<th>客户经理</th>
								<th>客户名称</th>
								<th>应收金额</th>
								<th>2日以上应收金额</th>
								<th>账龄</th>
							</tr>
							<tbody ng-repeat='item in FenGongsi.companys'>
									<td rowspan="{{item.itemList.length+1}}">{{item.name}}</td>
									<tr ng-repeat='itme1 in item.itemList'>
										<td>{{itme1.CreateName}}</td>
										<td>{{itme1.CustomName}}</td>
										<td>{{itme1.RealPrice}}</td>
										<td>{{itme1.TwodaysRealPrice}}</td>
										<td>{{itme1.AgingDay}}</td>
									</tr>
									<tr style="background:#ddd">
										<td colspan="3" >小计</td>
										<td>{{item.total.RealPrice}}</td>
										<td>{{item.total.TwodaysRealPrice}}</td>
										<td>{{}}</td>
									</tr>
							</tbody>
							
							<tr>
								<th colspan="3">合计</th>
								<th>{{FenGongsi.total.RealPrice}}</th>
								<th>{{FenGongsi.total.TwodaysRealPrice}}</th>
								<th></th>
							</tr>
						</table>
					</div>
					<!-- 库存权益 -->
					 <div style="width: 1000px; margin:0 auto;"> 
						<div class="bb-content3" ng-if="tab==3">
							  <!-- $scope.workEath$scope.Inventory -->
							  <table border='1px'>
									<tr style="font-size: 22px;">
										<th>供应单位名称</th>
										<th>定价未售数量</th>
										<th>库存数量</th>
										<th>在途数量</th>
										<th>库存均价</th>
										<th>售价</th>
										<th>利差</th>
										<th>毛利额</th>
										<th style="position: relative;">出场未定价数量
											<div style="position: absolute; width: 60px;right:-60px;">
												<i class="fa fa-hand-o-down fa-2x" ng-click='allzhankai()' aria-hidden="true"></i>
												<i class="fa fa-hand-o-up fa-2x" ng-click='allshouqi()' aria-hidden="true"></i>
											</div>
										</th>
									</tr>
									<tbody ng-repeat='item in Inventoryaa track by $index' >
										
										<tr class="xiaohsi"  style="position: relative;background:#D9E9F5;">
											<td >
												<div style="width: 60px;height: 20px;position: absolute; left: -60px">
													<i class="fa fa-plus-circle zhankai" ng-click='zhankai()' aria-hidden="true"></i>
													<i class="fa fa-minus-circle shouqi" ng-click='shouqi()' aria-hidden="true"></i>
												</div>
												{{item.total.name}}
											</td>
											<td>
											{{item.total.weishou}}</td>
											<td>
											{{item.total.kucun}}
											</td>
											<td>
											{{item.total.zaitu}}
											</td>
											<td>
											{{item.total.junjia}}
											</td>
											<td>
											{{item.total.shoujia}}
											</td>
											<td>
											{{item.total.licha}}
											</td>
											<td>
											{{item.total.maoli}}
											</td>
											<td>
											{{item.total.weiding}}
											</td>
											
										</tr>
										<tr ng-repeat='item2 in item.arr' style="color: #aaa">
													<td style="text-align: right">{{item2.cangku}}</td>
													<td>{{item2.djwssl}}</td>
													<td>{{item2.kcsl}}</td>
													<td>{{item2.ztsl}}</td>
													<td>{{item2.kcjjg}}</td>
													<td>{{item2.shoujia}}</td>
													<td>{{item2.licha}}</td>
													<td>{{item2.maolie}}</td>
													<td>{{item2.ccwdsl}}</td>
										</tr>
									</tbody>
									
							  </table>
						<!--<div class="table-responsive">
			                <table id="example1" class="table table-striped b-t b-light table-bordered bb-table">
			                    <thead>
			                    <tr>
			                        <th style="text-align: center;" ng-repeat="item in neworders[0] track by $index">{{item}}</th>
			                    </tr>
			                    </thead>
			                    <tbody>
			                        <tr ng-repeat="ord in orders track by $index">
			                            <td class="text-center" ng-repeat="item in ord track by $index">{{item}}</td>
			                        </tr>
			                    </tbody>
			                </table>
			            </div>-->
					</div>
					 </div> 
					
				</div>
		    </div>
	</div>
    
</div>
<script >
 angular.module('app')
    .controller("Daytake", function ($scope, $state, $http, $filter) {
    //切换显示
    	 $scope.dept = "";
    	 $scope.QuYu='';
         $scope.providerType='';
         $scope.endTime=null;
         $scope.startTime=null;
        $scope.aa=null;
       	 //$scope.startTime1 = $scope.startTime.format('yyyy-MM-dd');//$filter("date")($scope.startTime, "yyyy-MM-dd");
 	 	// $scope.endTime1 = $filter("date")($scope.endTime, "yyyy-MM-dd");
         
    //显示日期选项
     $scope.down=function(){
     	$scope.clic=1;
     	$('.morediv').eq(0).css({top:'0px',transition:'.5s'});
     }
     //隐藏日期选项
     $scope.upload=function(){
     	$scope.clic=2;
     	$('.morediv').eq(0).css({top:'-230px',transition:'.5s'});
     }//显示日期选项
     $scope.update=function(){
     	 $scope.providerType='';
         $scope.endTime=null;
         $scope.startTime=new Date(($scope.endTime/1000-86400)*1000);
         $scope.GetCaixiao();
     }
     
     $scope.allshouqi=function(){

     	for (var i = 0; i < $scope.Inventoryaa.length; i++) {
     		$scope.Inventoryaa[i].arr=[];
     		$('.zhankai').eq(i).show('300')
     		$('.shouqi').eq(i).hide('300')	
     	}
     }
     $scope.shouqi=function(){
     	for (var i = 0; i < $scope.Inventoryaa.length; i++) {
     		
     		if (this.$index==i) {
     			$('.zhankai').eq(i).show('300')
     			$('.shouqi').eq(i).hide('300')
     			$scope.Inventoryaa[i].arr=[];
     		}
     		
     	}
     }
     $scope.zhankai=function(){
     	for (var i = 0; i < $scope.Inventoryaa.length; i++) {
     		if (this.$index==i) {
     			$('.zhankai').eq(i).hide('300')
     			$('.shouqi').eq(i).show('300')
     			$scope.Inventoryaa[i].arr=$scope.Inventorya[i].arr;
     		}
     	}
     }
      $scope.allzhankai=function(){
      	
     	for (var i = 0; i < $scope.Inventoryaa.length; i++) {
     		
     		$scope.Inventoryaa[i].arr=$scope.Inventorya[i].arr
     		$('.zhankai').eq(i).hide('300')
     		$('.shouqi').eq(i).show('300')	

     	}
     }
    //获取采销数据
 	 $scope.GetCaixiao=function(){
 	 	//时间格式转化
 	 	$scope.startTime=new Date(($scope.endTime/1000-86400)*1000);
 	 	$scope.startTime1 = $scope.startTime.format('yyyy-MM-dd');//$filter("date")($scope.startTime, "yyyy-MM-dd");
 	 	 $scope.endTime1 = $filter("date")($scope.endTime, "yyyy-MM-dd");
 	 	console.log($scope.startTime1,$scope.endTime1)
 	 	if ($scope.startTime>$scope.endTime) {
 	 		alert('请输入正确的查询条件')
 	 		$scope.providerType='';
         	$scope.endTime=new Date();
         	$scope.startTime=new Date(($scope.endTime/1000-86400)*1000);
 	 	}else{
 		$http({
                url: "../api/Report/GetSalesReport?isHander=true&startTime="+$scope.startTime1+"&endTime="+$scope.endTime1+"&providerType="+$scope.providerType,
                method: "GET"
            })
                    .then(function (res) {
                        console.log(res.data);
                        $scope.gangchang=[];
        				$scope.cangku=[];
        				$scope.jingxiao=[];	
                        $scope.providers = res.data;
                        for (var i = 0; i <  $scope.providers.length; i++) {
                        	if ($scope.providers[i].ProviderType==0) {
                        		$scope.gangchang.push($scope.providers[i])
                        	}else if($scope.providers[i].ProviderType==1){
                        		$scope.cangku.push($scope.providers[i])
                        	}else{
                        		$scope.jingxiao.push($scope.providers[i])
                        	}
                        }
                        console.log($scope.gangchang)
                        console.log($scope.cangku)
                        console.log($scope.jingxiao)
                        //遍历保存钢厂值///////////////////
                        $scope.arrSumG=[];
                        angular.forEach($scope.gangchang[0],function(v,k){
                        	$scope.arrSumG[k]=$scope.smallAddG(k)
                        });
                        //遍历保存仓库值//////////////////////////
                        $scope.arrSumC=[];
                        angular.forEach($scope.cangku[0],function(v,k){
                        	$scope.arrSumC[k]=$scope.smallAddC(k)
                        })
                        //遍历保存经销商值//////////////////////////
                        $scope.arrSumJ=[];
                        angular.forEach($scope.jingxiao[0],function(v,k){
                        	$scope.arrSumJ[k]=$scope.smallAddJ(k)
                        })
                    })
                    .then(function (error) {
                        if (error) {
                            alert("数据获取失败");
                        }
                    });
        }
 	};
 	//
 	 //获取应收账务数据 
 	 $scope.GetYingshou=function(){
 	 	$scope.startTime=new Date(($scope.endTime/1000-86400)*1000);
 	 	$scope.startTime1 = $scope.startTime.format('yyyy-MM-dd');//$filter("date")($scope.startTime, "yyyy-MM-dd");
 	 	 $scope.endTime1 = $filter("date")($scope.endTime, "yyyy-MM-dd");
 	 	

 	 	$http({
                url: "../api/Report/GetAccountsReportList?isHander=true&startTime="+$scope.startTime1+"&endTime="+$scope.endTime1+"&deptId="+$scope.dept.Id,
                method: "GET"
            })
                    .then(function (res) {
                    	console.log(res.data);
                        $scope.FenGongsi=$scope.mapCompany(res.data)
                       console.log($scope.FenGongsi);
 	 					 $scope.arr = [];
        				 $scope.arrT=[];
						angular.forEach( $scope.FenGongsi.companys, function(value, key) {
						  this.push({value:value.total.RealPrice, name:key});
						}, $scope.arr);
						angular.forEach( $scope.FenGongsi.companys, function(value, key) {
						  this.push({Id:value.Id, name:key});
						}, $scope.arrT);
						console.log($scope.arr,111111111111111111);

						 $scope.legendData = [ ];
						for (var i = 0; i < $scope.arr.length; i++) {
							$scope.legendData.push($scope.arr[i].name)
						}
     //                    	// 基于准备好的dom，初始化echarts实例
	var myChart = echarts.init(document.getElementById('eath'));
 	// 指定图表的配置项和数据
	var option = {
		    title : {
		        text: '应收分布(区域)',
		        x:'center'
		    },
		    tooltip : {
		        trigger: 'item',
		        formatter: "{a} <br/>{b} : {c} ({d}%)"
		    },
		    legend: {
		        orient: 'vertical',
		        left: 'left',
		        data: $scope.legendData
		    },
		    series : [
		        {
		            name: '访问来源',
		            type: 'pie',
		            radius : '55%',
		            center: ['50%', '60%'],
		            data:$scope.arr,
		            itemStyle: {
		                emphasis: {
		                    shadowBlur: 10,
		                    shadowOffsetX: 0,
		                    shadowColor: 'rgba(0, 0, 0, 0.5)'
		                }
		            }
		        }
		    ]
		};
		myChart.setOption(option);
                       console.log($scope.mapCompany(res.data))
                    })
                    .then(function (error) {
                        if (error) {
                            alert("数据获取失败");
                        }
                    });
                    //获取应收款项占比
                    console.log($scope.dept.id);
                    $scope.startTime1 = $scope.startTime.format('yyyy-MM-dd');//$filter("date")($scope.startTime, "yyyy-MM-dd");
 	 				 $scope.endTime1 = $filter("date")($scope.endTime, "yyyy-MM-dd");
        $http({
                url: "../api/Report/GetAccountsTypeReportList?isHander=true&startTime="+$scope.startTime1+"&endTime="+$scope.endTime1+"&deptId="+$scope.dept.Id,
                method: "GET"
            })
                    .then(function (res) {
                    	console.log('..........................................');
                    	console.log(res.data);
                    	$scope.gongHu=[];
          				$scope.siHu=[];
                    	for (var i = 0; i < res.data.length; i++) {
                    		if (res.data[i].IsPublicDelivery==true){
                    			$scope.gongHu.push(res.data[i])
                    		}	else{
                    			$scope.siHu.push(res.data[i]);
                    		}
                    	}
                    	$scope.gonghu=$scope.gongHu.length;
                    	$scope.sihu=$scope.siHu.length;
                    	console.log($scope.siHu.length);
                    	console.log($scope.gonghu);
                    	        //应收分布区域饼图
							var myChart1 = echarts.init(document.getElementById('hutou'));
							var option1 = {
							    title : {
							        text: '应收款项占比(账户类型)',
							        x:'center'
							    },
							    tooltip : {
							        trigger: 'item',
							        formatter: "{a} <br/>{b} : {c} ({d}%)"
							    },
							    legend: {
							        orient: 'vertical',
							        left: 'left',
							        data: ['私户占比','公户占比']
							    },
							    series : [
							        {
							            name: '访问来源',
							            type: 'pie',
							            radius : '55%',
							            center: ['50%', '60%'],
							            data:[
							                {value:$scope.sihu, name:'私户占比'},
							                {value:$scope.gonghu, name:'公户占比'}
							            ],
							            itemStyle: {
							                emphasis: {
							                    shadowBlur: 10,
							                    shadowOffsetX: 0,
							                    shadowColor: 'rgba(0, 0, 0, 0.5)'
							                }
							            }
							        }
							    ]
							};
							myChart1.setOption(option1);
					        //公私户使用情况饼图
                    }).then(function (error) {
                        if (error) {
                            alert("数据获取失败");
                        }
                    });

 	 }
 	$scope.Getkucun = function () {
                    $http({
                        url: "../api/Report/NowDepotProfit?dt=" + $scope.endtime,
                        method: "GET"
                    })
                            .then(function (res) {
                                $scope.orders = res.data;
                                $scope.neworders = $scope.orders.splice(0,1);
                                console.log($scope.orders);
                            })
                            .then(function (error) {
                                if (error) {
                                    alert("数据获取失败");
                                }
                            });
				     $http.get('../api/Report/GetNowDepotProfitReportList?supplierId=null')
				     .success(function (res) {
				         console.log(res)
				         $scope.Inventorya=$scope.Inventoryab(res);
				         console.log($scope.Inventoryab(res))
				         $scope.Inventoryaa=$scope.Inventoryab(res);
				       for (var i = 0; i < $scope.Inventoryaa.length; i++) {
				     		$('.shouqi').eq(i).show('300')
				     		$('.zhankai').eq(i).hide('300')
				     		$scope.Inventoryaa[i].arr=$scope.Inventorya[i].arr
						}
					    
				     });
                };
       $scope.Getkucun()
	$scope.Inventoryab=function(dataArray){
		var total={
			name : '',
			weishou : 0,
			kucun : 0,
			zaitu : 0,
			junjia : 0,
			shoujia : 0,
			licha : 0,
			maoli : 0,
			weiding:0

		}
	var arr=[];
	var bigarr=[];
	var bigobj={
			arr:[],
			total:{}
		};
	var arrtotal=[];
	var allInventory={};
		var changName= '';
		for (var i = 0; i < dataArray.length; i++) {
			var item=dataArray[i];
			var companyObja = allInventory[item['changjia']];
			if (companyObja==null) {
				companyObja = {};
				companyObja.itemList = [];
				companyObja.total={
								weiding:0,
								name : "",
								weishou : 0,
								kucun : 0,
								zaitu : 0,
								junjia : 0,
								shoujia : 0,
								licha : 0,
								maoli : 0
							}
				if(companyObja.itemList!=null){	

					
					companyObja.itemList.push(companyObja.total)
					arr.push(companyObja.itemList);
				}
				allInventory[item['changjia']]=companyObja;
			}
			companyObja.itemList.push(item);
			companyObja.total.weiding += item['ccwdsl'];
			companyObja.total.weishou += item['djwssl'];
			companyObja.total.kucun += item['kcsl'];
			companyObja.total.zaitu += item['ztsl'];
			companyObja.total.junjia += item['kcjj'];
			companyObja.total.shoujia += item['shoujia'];
			companyObja.total.licha += item['licha'];
			companyObja.total.maoli += item['maolie'];
			companyObja.total.name = item['changjia'];
			//////////////////////////////////////////////////////
			//////////////////////////////////////////////////////
			total.weishou += item['djwssl'];
			total.kucun += item['kcsl'];
			total.zaitu += item['ztsl'];
			total.junjia += item['kcjj'];
			total.shoujia += item['shoujia'];
			total.licha += item['licha'];
			total.maoli += item['maolie'];
			total.name = item['changjia'];
			total.weiding += item['ccwdsl'];


		}
		// console.log(allInventory)
		// console.log(total)
		console.log(companyObja,88888);
		console.log(arr,111111111111);
		// return bigarr
		var newArr = []
		for(var i = 0 ; i < arr.length; i++){
			var nawObj = {
				total:{},
				arr:[]
			}
			for(var j = 0; j < arr[i].length; j++){
				if (j==0) {
					nawObj.total = arr[i][j]
				}else {
					nawObj.arr.push(arr[i][j])
				}
			}
			newArr.push(nawObj)
		}
		return newArr
		// [arr,arrtotal,total]
			
	}
	$scope.mapCompany=function(dataArray){
		var allCompanyObject = {};
		var total = {
			RealPrice:0,
			TwodaysRealPrice:0
		};
		for (var i = 0; i < dataArray.length; i++) {
			var item = dataArray[i];
			var companyObj = allCompanyObject[item.DepartName];
			if(companyObj == null){
				companyObj = {};
				companyObj.Id= item.DeptId;
				companyObj.name = item.DepartName;
				allCompanyObject[item.DepartName] = companyObj;
				companyObj.itemList = [];
				companyObj.total = {
					RealPrice:0,
					TwodaysRealPrice:0
				};
			}
			companyObj.itemList.push(item);
			companyObj.total.RealPrice += item.RealPrice;
			companyObj.total.TwodaysRealPrice += item.TwodaysRealPrice;
			total.RealPrice += item.RealPrice;
			total.TwodaysRealPrice += item.TwodaysRealPrice;
		}
		return {
			companys:allCompanyObject,
			total:total
		}
	}
	
	//获取大区数据
	  $http.get('../api/Department')
     .success(function (res) {
         $scope.departments = res.Data;
         $scope.traverseTree($scope.departments);
         $scope.dept = $scope.departments[0].Item2;
         console.log($scope.departments)
     });
        $scope.array = [];
        $scope.traverseTree = function (node) {
            for (var i = 0; i < node.length; i++) {
                var empty = '　└─';
                for (var j = 1; j < node[i].Item1; j++) {
                    empty = '　' + empty;
                }
                if (i != 0) {
                    node[i].Item2.Name = empty + node[i].Item2.Name;
                } else {
                    node[i].Item2.Name = '　' + node[i].Item2.Name;
                }
                $scope.array.push(node[i].Item2);
                console.log($scope.array)
            }

            $scope.array[0].selected = true;
        };
        //////
 	$scope.tab1=function(){
 		$scope.tab=1;
 			$('.bb-tab span').eq(2).css({color:'',borderBottom:''});
 			$('.bb-tab span').eq(1).css({color:'',borderBottom:''});
 			$('.bb-tab span').eq(0).css({color:'#1591FB',borderBottom:'2px solid #1591FB'});
 	  $scope.GetCaixiao()
 	}
 	$scope.tab2=function(){
 		$scope.tab=2;
 			$('.bb-tab span').eq(2).css({color:'',borderBottom:''});
 			$('.bb-tab span').eq(0).css({color:'',borderBottom:''});
 			$('.bb-tab span').eq(1).css({color:'#1591FB',borderBottom:'2px solid #1591FB'});
			$scope.GetYingshou()
 	}
 	$scope.tab3=function(){
 		$scope.tab=3;
 			$('.bb-tab span').eq(0).css({color:'',borderBottom:''});
 			$('.bb-tab span').eq(1).css({color:'',borderBottom:''});
 			$('.bb-tab span').eq(2).css({color:'#1591FB',borderBottom:'2px solid #1591FB'});
 			$scope.Getkucun();
 	}
 	//获取采销情况数据
	$scope.tab1();
	//钢厂小计
	$scope.smallAddG=function(ad){
				$scope.numa=0;
				// console.log($scope.gangchang);
               		for (var i = 0; i < $scope.gangchang.length; i++) {
               			
 							$scope.numa=$scope.numa+$scope.gangchang[i][ad];
 							// console.log($scope.gangchang[i]);
 						}
 						return $scope.numa;
             };
     //仓库小计
    $scope.smallAddC=function(ad){
				$scope.numa=0;
				// console.log($scope.gangchang);
               		for (var i = 0; i < $scope.cangku.length; i++) {
               			
 							$scope.numa=$scope.numa+$scope.cangku[i][ad];
 							// console.log($scope.gangchang[i]);
 						}
 						return $scope.numa;
             };
    //经销小计
    $scope.smallAddJ=function(ad){
				$scope.numa=0;
				// console.log($scope.gangchang);
               		for (var i = 0; i < $scope.jingxiao.length; i++) {
               			
 							$scope.numa=$scope.numa+$scope.jingxiao[i][ad];
 							// console.log($scope.gangchang[i]);
 						}
 						return $scope.numa;
             };         
    // $scope.smallAdd('DayCount')我需要在这用

});
</script>
